<include file="Core:Public:header" /> {:W('Navigation')}
<link rel="stylesheet" type="text/css" media="all" href="__PLUGIN__/daterangepicker/daterangepicker-bs3.css" />
<script type="text/javascript" src="__PLUGIN__/daterangepicker/moment.js"></script>
<script type="text/javascript" src="__PLUGIN__/daterangepicker/daterangepicker.js"></script>
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">
			</span>配送员订单列表
		</div>
		<div class="row-table-body">

			<div class="panel panel-default">
				<div class="panel-heading">
					<div class="form-horizontal pull-left select_time">
						<fieldset>
							<div class="control-group">
								<div class="controls">
									<div class="input-prepend input-group"><span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i>选择日期</span>
										<input type="text" readonly="readonly" style="width: 200px" name="reservation" id="reservation" class="form-control" value="<php>
								if($teamtime){
									echo $teamtime['t_start']." - " .$teamtime['t_end'];
								}else{
									echo date(" Y-m-d ",strtotime("-1 month ")) ." - " . date("Y-m-d ");
								}			
							</php>" placeholder="点击选择日期" />
									</div>
								</div>
							</div>
						</fieldset>
					</div>
					<div class="pull-left">
						<input name="t_start" id="t_start" type="hidden" value="<php>echo date(" Y-m-d ",strtotime("-1 month "));</php>" />
						<input name="t_end" id="t_end" type="hidden" value="<php>echo date(" Y-m-d ");</php>" />
						<button id="so" type="button" class="btn btn-danger">查询</button>
					</div>

					<script type="text/javascript">
						$(document).ready(function() {
							$('#reservation').daterangepicker(null, function(start, end, label) {
								console.log(start.toISOString(), end.toISOString(), label);
							});
						});
					</script>
					　
					<a class="pull-right btn btn-primary btn-xs" href="javascript:;" id="import_team">导入订单数据</a> 
					<div class="clear"></div>
					<div class="well teamset form-inline">
						<volist name="teamset" id="vs" key="k">
							<div class="form-group checkbox">
								<input id="teamset{$k}" class="teamsetid" type="checkbox" name="teamid[]" value="{$vs.teamid}" <php> foreach($teamid as $kkk){ if($kkk == $vs['teamid']){ echo 'checked="checked"'; } }

								</php>
								/>
								<label for="teamset{$k}">{$vs.teamname}</label>
							</div>
						</volist>
					</div>
				</div>
				<div class="panel-body">
					<table class="table table-hover table-striped les">
						<thead>
							<tr>
								<th>日期</th>
								<th>配送员</th>
								<th>团队名称</th>
								<th>状态</th>
								<th>是否违规</th>
								<th>基础配送费</th>
								<th>提点</th>
								<th>调度超时</th>
								<th>异常扣款</th>
								<th>价值</th>

							</tr>
						</thead>
						<tbody>
							<volist name="olist" id="vo">
								<tr>
									<!--<td>{$vo._id}</td>-->
									<td>{$vo.adddate}</td>
									<td>{$vo.psname}</td>
									<td>{$vo.teamname}</td>
									<td>
										<switch name="vo.status">
										    <case value="1">正常</case>
										    <case value="2">超时</case>
										    <case value="0">疑似欺诈</case>
										    <case value="3">异常</case>
										</switch>
									</td>
									<td>
										<switch name="vo.vio">
										    <case value="1">是</case>
										    <case value="0">否</case>
										</switch></td>
									<td>{$vo.base}</td>
									<td>{$vo.tidian}</td>
									<td>{$vo.ddcs}</td>
									<td>{$vo.yckk}</td>
									<td>{$vo.value}</td>
								</tr>
							</volist>
						</tbody>
					</table>

				</div>
			</div>
			<div class="col-md-12">{$page}</div>

		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">
	var t_end;
	var t_start;
	$(function() {
		
		
		$("#so").click(function() {
			t_end = $("[name='daterangepicker_end']").val();
			t_start = $("[name='daterangepicker_start']").val();

			var jsons = {};
			var team = {};
			i = 0;
			$('.teamsetid').each(function() {
				if ($(this).is(':checked')) {
					i++
					team[i] = $(this).val();
				}
			});
			teamjson = encodeURI(JSON.stringify(team));
			//			alert(teamjson);return false;
			if (teamjson == '%7B%7D') {
				window.location.href = "{:U('chrm/delivery/li')}&t_start=" + t_start + "&t_end=" + t_end;
			} else {
				window.location.href = "{:U('chrm/delivery/li')}&t_start=" + t_start + "&t_end=" + t_end + "&teamid=" + teamjson;
			}

		});
	});

	function strToJson(str) {
		var json = eval('(' + str + ')');
		return json;
	}
	$('#import_team').click(function(){
		$('#alert').modal({
			show:true,
			remote:'{:U("chrm/delivery/upload")}'
		});
	});
</script>
<include file="Core:Public:alert" />
<include file="Core:Public:footer" />